export default {
  addCart(context, payload) {
    return new Promise((resolve) => {
      let oldProduct = context.state.cartList.find(
        (value) => value.iid === payload.iid
      ); //找有没有添加 ,有返回该对象,没有返回undefined
      if (oldProduct) {
        context.commit("addCount", oldProduct);
        resolve("当前商品数量+1");
      } else {
        payload.count = 1;
        context.commit("addToCat", payload);
        resolve("添加了新的商品");
      }
    });
  }, //更新buylist
  aUpdateBuyList(context, payload) {
    return new Promise((resolve) => {
      context.commit("updateBuyList", payload);
      resolve("ok");
    });
  },
};
